package com.yang.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class ResponseResult {
    
    private Integer code;
    private String message;
    private Object data;

    public final static Integer SUCCESS=1;  //成功
    public final static Integer FAIL=0;     //失败

    public static ResponseResult success(){

        return ResponseResult.builder()
                .code(SUCCESS)
                .message("操作成功")
                .data(null)
                .build();
    }

    public static ResponseResult success(Object data){

        return ResponseResult.builder()
                .code(SUCCESS)
                .message("操作成功")
                .data(data)
                .build();
    }

    public static ResponseResult success(String message,Object data){

        return ResponseResult.builder()
                .code(SUCCESS)
                .message(message)
                .data(data)
                .build();
    }

    public static ResponseResult fail(){
        return ResponseResult.builder()
                .code(FAIL)
                .message("操作失败")
                .data(null)
                .build();
    }

    public static ResponseResult fail(String message){
        return ResponseResult.builder()
                .code(FAIL)
                .message(message)
                .data(null)
                .build();
    }
    

}
